package cn.gok;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.Properties;
import java.util.Set;

public class Properties工具类 {
    public static void main(String[] args) throws IOException {
        Properties pro=new Properties();

        pro.setProperty("name","ljy");
        pro.setProperty("password1","123456");
        System.out.println(pro);


        Reader rd=new FileReader("");
        pro.load(rd);
        System.out.println(pro.getProperty("name"));
        System.out.println(pro.getProperty("driver"));
        System.out.println(pro.getProperty("username"));
        System.out.println("password");


        //第二种方法
        Set<String> keys=pro.stringPropertyNames();

        for(String s:keys){
            System.out.println(s);
            System.out.println(pro.getProperty(s));
        }
    }
}
